<?php

// 
// this takes break.com alphanumeric+  id and returns a JSON object for that item
//
// Sample call:  http://joemaller.com/services/break_extractor.php?break=NDY4NTQ4&callback=?   (note that jQuery should add the callback)
// 

# set up timer variables
$time = explode(" ", microtime()); 
$stime = $time[1] . substr($time[0],1,strlen($time[0])); 

# load the playback page with the new id
$headers = get_headers('http://embed.my.break.com/Common/Embed/Redirector.aspx?Contentid=' . htmlspecialchars($_GET['break']), 1);

parse_str( urldecode($headers['Location']), $break );

// get execution time
$time2 = explode (" ",microtime ()); 
$etime = $time2[1] . substr($time2[0],1,strlen($time2 [0])); 

// return the JSON object:
echo htmlspecialchars(
	$_GET['callback'] ) 
	. '({ "_id":"' . $break['iContentID'] 
	. '", "_type":"break.com'
	. '", "_typeLabel":"Break.com'
	. '", "_img":"' . $break['sThumbLoc'] 
	. '", "_page":"' . $break['contentURL'] 
	. '", "_title":"Video Page'
    // . '", "_title":"' . substr(array_pop(explode('/', $break['sThumbLoc'])), 0, -4)
	. '", "execution_time":' . round($etime - $stime,4) 
	. ' })';

?>